import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firstdemo/cookbook/ImageEx.dart';
import 'package:firstdemo/cookbook/ListViewEx.dart';
import 'package:firstdemo/cookbook/GridViewEx.dart';
import 'package:firstdemo/cookbook/GestureDetectorEx.dart';
import 'package:firstdemo/cookbook/NavigatorEx.dart';
import 'package:firstdemo/cookbook/NavigatorPopEx.dart';
import 'package:firstdemo/cookbook/HttpEx.dart';
import 'package:firstdemo/cookbook/WebSocketsEx.dart';
class CookBook extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Flutter Cookbook 示例'),),
      body: ListView(
        children: [
          ListTile(title: Text('Image 示例'),onTap: (){
            goToPage(context, ImageEx());
          },),
          Divider(),
          ListTile(title: Text('ListView混合数据 示例'),onTap: (){
            goToPage(context, ListViewEx());
          },),
          Divider(),
          ListTile(title: Text('GridView 示例'),onTap: (){
            goToPage(context, GridViewEx());
          },),
          Divider(),
          ListTile(title: Text('GestureDetector 示例'),onTap: (){
            goToPage(context, GestureDetectorEx());
          },),
          Divider(),
          ListTile(title: Text('Navigator传递 示例'),onTap: (){
            goToPage(context, NavigatorEx());
          },),
          Divider(),
          ListTile(title: Text('Navigator pop传递 示例'),onTap: (){
            goToPage(context, NavigatorPopEx());
          },),
          Divider(),
          ListTile(title: Text('Http 简单请求 示例'),onTap: (){
            goToPage(context, HttpEx());
          },),
          Divider(),
          ListTile(title: Text('websocket 简单 示例'),onTap: (){
            goToPage(context, WebSocketsEx());
          },),
        ],
      ),
    );
  }
}

goToPage(BuildContext context, Widget widget){
  Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context){
    return widget;
  }));
}